package AnalogClock;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;


public class ClockFrame extends JFrame{

	private static final long serialVersionUID = 1L;
	private JLabel l;
	private Clock c; 
	private Timer t;
	private ClockIcon i;

	public ClockFrame(){
		l = new JLabel();
		c = new Clock();
		i = new ClockIcon(c);

		this.setLayout(new GridLayout(1,0));
		this.add(c);
		
		l.setIcon(i);

		t = new Timer(1000,
				new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				c.update();
			}
		});
		t.start();
		pack();
	}

	/**
	 * Main
	 * @param args
	 */
	 public static void main(String[] args) {
		 ClockFrame window = new ClockFrame();
		 window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 window.setVisible(true);
	 }

}
